Library.WebControl.Ajax = (function() {
  function ajaxRequest() {
    var _data = null;
    var _requestUrl = _spglobalRequestUrl;
    this.SetData = function(data) {
      _data = data;
    };
    this.SetUrl = function(url) {
      _requestUrl = url;
    };
    this.SendCallback = function(sender, functionCallback) {
      var request = Library.WebControl.Ajax.HttpRequest();

      if (request == null) {
        alert("Init ajax request fail");
        return;
      }
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          if (request.status == 200) {
            if (functionCallback && typeof (functionCallback) == 'function') {
              var args = {
                ResponseXml: request.responseXML,
                ResponseText: request.responseText
              };
              functionCallback(sender, args);
            }
          }
        }
      };

      request.open("POST", _requestUrl, true);
      request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      request.setRequestHeader("encoding", "UTF-8");
      var requestData = "__SPAXRQ_=T";
      if (_data != null) {
        requestData += "&" + _data;
      }

      request.setRequestHeader("Content-Length", requestData.length);
      request.send(requestData);
    };
    function initiateRequest() {

    };
  };

  return {
    CreateRequest: function() {
      return new ajaxRequest();
    },
    HttpRequest: function() {
      if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
      }
      else
        if (window.ActiveXObject) {
        try {
          return new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
          try {
            return new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (E) {
            return null;
          }
        }
      }
      else
        return null;
    }
  }
} ());

Library.WebControl.Hashtable = (function() {
  function SimpleHashtable() {
    var _ir = new Array();
    this.Get = function(id) {
      for (var i = 0; i < _ir.length; i++) {
        var obj = _ir[i];
        if (obj.Id == id) {
          return obj;
        }
      }

      return null;
    };
    this.Remove = function(id) {
      for (var i = 0; i < _ir.length; i++) {
        var obj = _ir[i];
        if (obj.Id == id) {
          _ir.slice(i, 1);
          return;
        }
      }
    };
    this.Add = function(id, value) {
      this.Remove(id);
      _ir.push({
        Id: id,
        Value: value
      });
    };
    this.GetAll = function() {
      return _ir;
    };
    this.Clear = function() {
      _ir = new Array();
    };
    this.ToQuery = function() {
      var q = '';
      for (var i = 0; i < _ir.length; i++) {
        var o = _ir[i];
        q += '&' + o.Id + '=' + encodeURIComponent(o.Value);
      }
      if (q.length > 0)
        return q.substring(1);
      else
        return '';
    };
  };
  return {
    CreateHashtable: function() {
      return new SimpleHashtable();
    }
  }
} ());


var _globalHashObject = Library.WebControl.Hashtable.CreateHashtable();
